//
//  LGCancerMonitorTemperatureCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/8/30.
//

#import "LGCancerMonitorTemperatureCell.h"

#define leftMargin   viewPix(58)
#define itemWidth    (Screen_W-viewPix(32)-leftMargin-viewPix(10))/2.0 //viewPix(90)

@interface LGCancerMonitorTemperatureCell()
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UIButton *contentBtn1;
/**   */
@property (nonatomic , strong)UIButton *contentBtn2;

@end

@implementation LGCancerMonitorTemperatureCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.baseView.backgroundColor = [UIColor colorWithString:@"#F5FBFF"];
        [self createSubView];
    }
    return  self;
}

-(void)setType:(LGPositionType)type{
    [super setType:type];
    CGFloat bottom = (type == LGPositionTypeBottom)?-viewPix(25):-viewPix(8);
    [self.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(bottom);
    }];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.timeLabel.text = LGNSString(dataDic[@"record_time"]);
    NSString *source = LGNSString(dataDic[@"source"]);
    NSString *content1 = [source isEqualToString:@"add"]?@"手动记录":[NSString stringWithFormat:@"%@",dataDic[@"position"]];
    NSString *content2 = [LGNSString(dataDic[@"t"]) isEmptyString]?@"--":LGNSString(dataDic[@"t"]);
    [self.contentBtn1 setTitle:content1 forState:UIControlStateNormal];
    [self.contentBtn2 setTitle:content2 forState:UIControlStateNormal];

//    if ([self.cellType isEqualToString:@"temperature"]) {
//        //体温
//        NSDictionary *iconDic = @{@"2":@"监测分数-偏高",@"1":@"监测分数-偏低"};
//        [self.contentBtn setTitle:LGNSString(dataDic[@"t"]) forState:UIControlStateNormal];
//        NSString *iconName = [dataDic[@"t_status"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"t_status"])];
////        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
//
//    }else if ([self.cellType isEqualToString:@"oxygen"]){
//        //血氧
//        NSDictionary *iconDic = @{@"2":@"监测分数-偏高",@"1":@"监测分数-偏低"};
//        [self.contentBtn setTitle:LGNSString(dataDic[@"spo"]) forState:UIControlStateNormal];
//        NSString *iconName = [dataDic[@"status"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"status"])];
////        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
//    }else{
//        //体重
//        NSDictionary *iconDic = @{@"偏高":@"监测分数-偏高",@"down":@"监测分数-偏低"};
//        [self.contentBtn setTitle:LGNSString(dataDic[@"weight"]) forState:UIControlStateNormal];
//        NSString *iconName = [dataDic[@"weightdiffstatus"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"weightdiffstatus"])];
////        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
//    }
//    [self.contentBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:3];
}


-(void)createSubView{
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.contentBtn1];
    [self.contentView addSubview:self.contentBtn2];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.top.equalTo(self.contentView).offset(viewPix(8));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
    [self.contentBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(leftMargin+viewPix(16));
        make.centerY.equalTo(self.timeLabel);
        make.width.equalTo(@(itemWidth+viewPix(20)));
        make.height.equalTo(@(viewPix(35)));
    }];
    [self.contentBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentBtn1.mas_right);
        make.centerY.height.equalTo(self.contentBtn1);
        make.width.equalTo(@(itemWidth-viewPix(20)));
    }];
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UIButton *)contentBtn1{
    if(!_contentBtn1){
        _contentBtn1 = [UIButton buttonWithTitle:@"" titleFont:LGFont(16) textColor:@"#282828" imageName:@""];
        _contentBtn1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _contentBtn1.userInteractionEnabled = NO;
    }
    return _contentBtn1;
}

-(UIButton *)contentBtn2{
    if(!_contentBtn2){
        _contentBtn2 = [UIButton buttonWithTitle:@"" titleFont:LGFont(16) textColor:@"#282828" imageName:@""];
        _contentBtn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _contentBtn2.userInteractionEnabled = NO;
    }
    return _contentBtn2;
}


@end
